
package com.eyedog.video.videolist;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewStub;
import android.widget.ImageView;
import android.widget.TextView;

import com.eyedog.uilibrary.base.BaseActivity;
import com.eyedog.video.R;

public class VideoListActivity extends BaseActivity implements View.OnClickListener {

    ImageView ivClose;

    TextView textView;

    public static Bundle createVideoListBundle(int categoryId, String title) {
        Bundle data = VideoListFragment.createVideoListBundle(categoryId);
        data.putString("title", title);
        return data;
    }

    public static Bundle createVideoListBundle(String keywords, String title) {
        Bundle data = VideoListFragment.createVideoListBundle(keywords);
        data.putString("title", title);
        return data;
    }

    @Override
    protected void onContentCreated(ViewStub contentLayout) {
        contentLayout.setLayoutResource(R.layout.activity_video_list);
        contentLayout.inflate();

        VideoListFragment videoListFragment = new VideoListFragment();
        Intent intent = getIntent();
        Bundle data = intent.getExtras();
        data.putBoolean("ISVideoListActivity",true);
        String title = data.getString("title");
        videoListFragment.setArguments(data);
        getSupportFragmentManager().beginTransaction().replace(R.id.fl_replace, videoListFragment)
                .commit();

        ivClose = (ImageView) findViewById(R.id.iv_close_button);
        ivClose.setOnClickListener(this);
        textView = (TextView) findViewById(R.id.tv_title);
        if (!TextUtils.isEmpty(title)) {
            textView.setText(title);
        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_close_button:
                finish();
                break;
        }
    }
}
